package main

import (
	"github.com/veandco/go-sdl2/img"
	"github.com/veandco/go-sdl2/sdl"
)

type Texture struct {
	t *sdl.Texture
}

func (this *Texture) LoadFromFile(path string) bool {
	img, err := img.Load(path)
	if err != nil {
		panic(err)
	}
	this.t, err = Grender.CreateTextureFromSurface(img)
	if err != nil {
		panic(err)
	}
	img.Free()

	return true
}

func (this *Texture) Render(src *sdl.Rect, dst *sdl.Rect) {
	Grender.Copy(this.t, src, dst)
}

func (this *Texture) setColor(r, g, b uint8) {
	this.t.SetColorMod(r, g, b)
}

func (this *Texture) SetAlpha(a uint8) {
	this.t.SetAlphaMod(a)
}

func (this *Texture) SetBlendMode(blend sdl.BlendMode) {
	this.t.SetBlendMode(blend)
}

func (this *Texture) Free() {
	this.t.Destroy()
}
